package MapDemo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Mapkey1 {
    public static void main(String[] args) {
        HashMap<String, String> hm = new HashMap<String, String>();
        //添加元素
        System.out.println(hm.put("乔峰", "阿朱姑娘"));
        System.out.println(hm.put("虚竹", "西夏公主"));
        System.out.println(hm.put("段誉", "王语嫣"));
        System.out.println(hm);   //概览
        Set<Map.Entry<String, String>> entries = hm.entrySet();
        //遍历entries  集合
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println("丈夫:" + key + "-------" + "媳妇:" + value);
        }

    }

}
